﻿<ui:DialogWindowVersioningWorkaround
    x:Class="Microsoft.NodejsTools.Profiling.LaunchProfiling"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="clr-namespace:Microsoft.NodejsTools.Profiling"
    xmlns:wpf="clr-namespace:Microsoft.VisualStudioTools.Wpf;assembly=Microsoft.NodejsTools"
    Title="Profiling Settings" 
    MinHeight="440" Width="700" 
    MinWidth="400"
    SizeToContent="Height"
    x:Name="LaunchProfilingWindow" 
    WindowStartupLocation="CenterOwner"
    ShowInTaskbar="False"
    Background="{DynamicResource {x:Static wpf:Controls.BackgroundKey}}"
    TextElement.Foreground="{DynamicResource {x:Static wpf:Controls.ForegroundKey}}"
    TextOptions.TextFormattingMode="Display"
    ResizeMode="CanResizeWithGrip">
    <Window.Resources>
        <ResourceDictionary Source="pack://application:,,,/Microsoft.NodejsTools;component/SharedProject/Wpf/Controls.xaml" />
    </Window.Resources>
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <Label Grid.Row="0" Content="What would you like to profile?" Margin="6 12 6 0" FontWeight="Bold" />

            <RadioButton Grid.Row="1" Margin="12 12 12 4"
                                 Content="_Open project"
                                 AutomationProperties.AutomationId="ProfileProject"
                                 GroupName="ProjectOrStandalone"
                                 IsEnabled="{Binding IsAnyAvailableProjects}"
                                 IsChecked="{Binding IsProjectSelected}" />
            <ComboBox Grid.Row="2"
                              IsEnabled="{Binding IsProjectSelected}"
                              ItemsSource="{Binding AvailableProjects}"
                              SelectedItem="{Binding Project}"
                              Margin="8 4" Padding="4 6" VerticalContentAlignment="Center"
                              DisplayMemberPath="Name"
                              AutomationProperties.AutomationId="Project" />

            <RadioButton Grid.Row="3" Margin="12 12 12 4"
                                 Content="S_tandalone script" 
                                 AutomationProperties.AutomationId="ProfileScript"
                                 GroupName="ProjectOrStandalone"
                                 IsChecked="{Binding IsStandaloneSelected}" />
            <GroupBox Grid.Row="4" Header="Script Options"
                              IsEnabled="{Binding IsStandaloneSelected}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>

                    <Label Grid.Row="1" Grid.Column="0" Content="_Node Path:"
                                   Padding="0" VerticalAlignment="Center" />
                    <Grid Grid.Row="1" Grid.Column="1" Margin="4">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <TextBox Grid.Column="0" 
                                         Text="{Binding Standalone.InterpreterPath,UpdateSourceTrigger=PropertyChanged}"
                                         AutomationProperties.AutomationId="Standalone.InterpreterPath" />
                        <Button Grid.Column="1" Margin="4 0 0 0" Content="..."
                                        Click="FindInterpreterClick"
                                        Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" />
                    </Grid>

                    <Label Grid.Row="2" Grid.Column="0" Content="Sc_ript:"
                                   Padding="0" VerticalAlignment="Center" />
                    <Grid Grid.Row="2" Grid.Column="1" Margin="4">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <TextBox Grid.Column="0" 
                                         Text="{Binding Standalone.ScriptPath,UpdateSourceTrigger=PropertyChanged}"
                                         AutomationProperties.AutomationId="Standalone.ScriptPath" />
                        <Button Grid.Column="1" Margin="4 0 0 0" Content="..."
                                        Click="FindScriptClick"
                                        Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" />
                    </Grid>

                    <Label Grid.Row="3" Grid.Column="0" Content="_Working Directory:"
                                   Padding="0" VerticalAlignment="Center" />
                    <Grid Grid.Row="3" Grid.Column="1" Margin="4">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>
                        <TextBox Grid.Column="0" 
                                         Text="{Binding Standalone.WorkingDirectory,UpdateSourceTrigger=PropertyChanged}" 
                                         AutomationProperties.AutomationId="Standalone.WorkingDirectory" />
                        <Button Grid.Column="1" Margin="4 0 0 0" Content="..." 
                                        Click="FindWorkingDirectoryClick"
                                        Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" />
                    </Grid>

                    <Label Grid.Row="4" Grid.Column="0" Content="Command Line _Arguments:"
                                   Padding="0" VerticalAlignment="Center" />
                    <TextBox Grid.Row="4" Grid.Column="1" Margin="4"
                                     Text="{Binding Standalone.Arguments,UpdateSourceTrigger=PropertyChanged}"
                                     AutomationProperties.AutomationId="Standalone.Arguments" />
                </Grid>
            </GroupBox>
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
            <Button IsDefault="True" Click="OkClick" IsEnabled="{Binding IsValid}"
                    MinWidth="86" MinHeight="24" 
                    AutomationProperties.AutomationId="Ok"
                    Content="{Binding StartText}"/>
            <Button IsCancel="True" Click="CancelClick" MinWidth="86" MinHeight="24"
                    AutomationProperties.AutomationId="Cancel">
                _Cancel
            </Button>
        </StackPanel>
    </Grid>
</ui:DialogWindowVersioningWorkaround>
